package com.cci.kangdao.fieldService.service.impl;

import com.cci.kangdao.fieldService.dao.FieldServiceWorkOrderFlowDao;
import com.cci.kangdao.fieldService.model.FieldServiceWorkOrder;
import com.cci.kangdao.fieldService.model.FieldServiceWorkOrderFlow;
import com.cci.kangdao.fieldService.model.type.WorkOrderFlowProcessorType;
import com.cci.kangdao.fieldService.service.FieldServiceWorkOrderFlowService;
import com.cci.kangdao.utilTool.LocalTimeUtil;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @author William Du
 * @date 2020/2/6
 */
@Service
public class FieldServiceWorkOrderFlowServiceImpl implements FieldServiceWorkOrderFlowService {

    @Resource
    private FieldServiceWorkOrderFlowDao fieldServiceWorkOrderFlowDao;

    @Override
    public void saveWorkOrderFlow(WorkOrderFlowProcessorType processorType, FieldServiceWorkOrder workOrder, Long processorId, String remarks) {
        FieldServiceWorkOrderFlow fieldServiceWorkOrderFlow = new FieldServiceWorkOrderFlow();
        fieldServiceWorkOrderFlow.setOrderId(workOrder.getId());
        fieldServiceWorkOrderFlow.setProcessorType(processorType.getCode());
        fieldServiceWorkOrderFlow.setOrderStatus(workOrder.getStatus());
        fieldServiceWorkOrderFlow.setRemarks(remarks);
        fieldServiceWorkOrderFlow.setCreator(processorId);
        fieldServiceWorkOrderFlow.setCreateTime(LocalTimeUtil.getRealCurrentTime());
        fieldServiceWorkOrderFlowDao.insertSelective(fieldServiceWorkOrderFlow);
    }

    @Override
    public void saveWorkOrderFlow(WorkOrderFlowProcessorType processorType, FieldServiceWorkOrder workOrder, Long processorId) {
        this.saveWorkOrderFlow(processorType, workOrder, processorId, null);
    }

}
